package jasongarrett.spida;

import java.io.IOException;
import java.util.List;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

// this class is no longer referenced, but it was helpful to me early on with marshalling/unmarshalling to/from json

public class JobJSONConverter
{
	public static Job jobFromJSON(String json) throws JsonParseException, JsonMappingException, IOException
	{
		Job job;
		ObjectMapper mapper = new ObjectMapper();
		job = mapper.readValue(json, Job.class);
		return job;
	}
	
	public static List<Job> jobsFromJSON(String json) throws JsonParseException, JsonMappingException, IOException
	{
		List<Job> jobs;
		ObjectMapper mapper = new ObjectMapper();
		jobs = mapper.readValue(json, new TypeReference<List<Job>>() {} );
		return jobs;
	}
}
